package kr.hkit.androidcomplete01.chaptert07;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

public class OffScreenEx extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new MyBitmap(this));
	}
	
	class MyBitmap extends View{
		Bitmap BackBit;
		Paint Pnt;
		public MyBitmap(Context context) {
			super(context);
		}

		@Override
		public void onDraw(Canvas canvas) {
			canvas.drawColor(Color.LTGRAY);
			Pnt = new Paint();
			
			BackBit = Bitmap.createBitmap(300, 200, Bitmap.Config.ARGB_8888);
			Canvas offscreen = new Canvas(BackBit);
			offscreen.drawColor(Color.GREEN);
			Pnt.setColor(Color.RED);
			for(int x = 0; x < 300; x += 10){
				offscreen.drawLine(x, 0, 300-x, 200, Pnt);
			}
			
			canvas.drawBitmap(BackBit, 10, 10, null);
			
		}
			
	}
}
